package com.bjsxt.service.impl;

import com.bjsxt.mapper.SysRoleMapper;
import com.bjsxt.service.SysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjsxt.mapper.SysMenuMapper;
import com.bjsxt.domain.SysMenu;
import com.bjsxt.service.SysMenuService;
@Service
public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> implements SysMenuService{
    @Autowired
    private SysRoleService sysRoleService;
    @Autowired
    private SysMenuMapper sysMenuMapper;
    @Override
    public List<SysMenu> getMenusByUserId(Long userId) {
        /**
         * 如果改用户是一个超级管理员拥有所有的菜单，否则不是超级管理员，则查询角色，进而查询菜单
         */
        if(sysRoleService.isSuperAdmin(userId)){
            return list();
        }
        return sysMenuMapper.selectMenusByUserId(userId);
    }
}
